package com.micro.ai.template.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * Agent实例实体
 *
 * @author micro-ai
 * @since 0.0.1
 */
@Data
@TableName(value = "agent_instances", autoResultMap = true)
@Schema(description = "Agent实例")
public class AgentInstance {

    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @Schema(description = "主键ID")
    private String id;

    @TableField("agent_id")
    @Schema(description = "Agent ID")
    private String agentId;

    @TableField("agent_name")
    @Schema(description = "Agent名称")
    private String agentName;

    @TableField("template_id")
    @Schema(description = "模板ID")
    private String templateId;

    @TableField("template_version")
    @Schema(description = "模板版本")
    private String templateVersion;

    @TableField("description")
    @Schema(description = "描述")
    private String description;

    @TableField(value = "config", typeHandler = JacksonTypeHandler.class)
    @Schema(description = "配置信息")
    private Map<String, Object> config;

    @TableField("status")
    @Schema(description = "状态(ACTIVE/INACTIVE/ERROR/UPDATING/DELETED)")
    private String status;

    @TableField("health_status")
    @Schema(description = "健康状态(HEALTHY/UNHEALTHY/UNKNOWN)")
    private String healthStatus;

    @TableField("last_health_check")
    @Schema(description = "最后健康检查时间")
    private LocalDateTime lastHealthCheck;

    @TableField(value = "tags", typeHandler = JacksonTypeHandler.class)
    @Schema(description = "标签列表")
    private List<String> tags;

    // ============================================================================
    // ✅ 多租户和用户关联
    // ============================================================================

    @TableField("tenant_id")
    @Schema(description = "所属租户ID", example = "tenant_001")
    private String tenantId;

    @TableField("created_by")
    @Schema(description = "创建者用户ID", example = "usr_001")
    private String createdBy;

    @TableField("created_at")
    @Schema(description = "创建时间")
    private LocalDateTime createdAt;

    @TableField("updated_at")
    @Schema(description = "更新时间")
    private LocalDateTime updatedAt;

    @TableField("deleted_at")
    @Schema(description = "删除时间（软删除）")
    private LocalDateTime deletedAt;
}

